﻿/*++
 * Copyright (c) DemeterSoft Corporation
 *
 * File Name:
 *     NavigationPart.cs
 *     
 * Abstract:
 *     导航面板，主要用于导航
 *
 * Revision History:
 *     08/29/2011    yliu
 *         创建文件
 * --*/
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using SmartSpace.UI.Silverlight;
using SmartSpace.UI.Silverlight.Theme;
using System.Windows.Media.Effects;
using System.Collections;
using System.Threading;

namespace SmartSpace.UI.Silverlight.Themes.Fashtion
{
    public partial class AlertMessagePanel : UserControl
    {
        public AlertMessagePanel()
        {
            InitializeComponent();

            borderLabel.Tag = m_headerTitle.Content;
        }

        public event Action<bool> NavigationPanelCollapsed;

        private void OnButtonCollapseClick(object sender, RoutedEventArgs e)
        {
            //this.Effect = null;

            borderLabel.Tag = m_headerTitle.Content;
            VisualStateManager.GoToState(borderLabel, "Collapsed", false);

            if (NavigationPanelCollapsed != null)
            {
                NavigationPanelCollapsed(true);
            }
        }

        private void OnButtonExpandedClick(object sender, RoutedEventArgs e)
        {
            //DropShadowEffect ds = new DropShadowEffect();
            //ds.ShadowDepth = 5;
            //ds.Direction = 135;
            //ds.Opacity = 0.5f;
            //ds.Color = Colors.Black;
            //this.Effect = ds;

            VisualStateManager.GoToState(borderLabel, "Expanded", false);
            if (NavigationPanelCollapsed != null)
            {
                NavigationPanelCollapsed(false);
            }
        }

        public void SwitchView(SlView view)
        {
            m_viewContainer.SwitchView(view);
        }

        private void Border_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            OnButtonCollapseClick(null, null);
        }

        private void BorderCollapse_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            OnButtonExpandedClick(null, null);
        }

        /// <summary>
        /// 第一次打开时默认显示，N秒后隐藏
        /// </summary>
        public void GoToCollapsed()
        {
            VisualStateManager.GoToState(borderLabel, "Collapsed", true);
        }
    }
}
